﻿using System;
namespace Producers.Liiklusregister.Xtee.Riik.Ee.Producer.Liiklusregister {
    
    
    [global::Xtee.Core.Attributes.XmlTypeAttribute(Name="pol_juhtoigus", Namespace="http://producers.liiklusregister.xtee.riik.ee/producer/liiklusregister", Target=typeof(PolJuhtoigus))]
    public class PolJuhtoigusSerializer : global::Xtee.Core.Types.AbstractXteeSerializable {
        
        protected IPolJuhtoigus clazz;
        
        public PolJuhtoigusSerializer(IPolJuhtoigus clazz) {
            this.clazz = clazz;
        }
        
        public override void WriteXml(global::Xtee.Core.IXteeXmlWriter Writer) {
            base.WriteXml(Writer);
            Writer.WriteStartElement("kat");
            if (clazz.Kat!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Kat))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : Kat");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("oigus");
            if (clazz.Oigus!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Oigus))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : Oigus");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("omistatud");
            if (clazz.Omistatud!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Omistatud))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : Omistatud");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("voetud_alates");
            if (clazz.VoetudAlates!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.VoetudAlates))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : VoetudAlates");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("voetud_kuni");
            if (clazz.VoetudKuni!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.VoetudKuni))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : VoetudKuni");
            }
            Writer.WriteEndElement();
        }
        
        public override void ReadXml(global::Xtee.Core.IXteeXmlReader Reader) {
            base.ReadXml(Reader);
        START:
            if ((Reader.LocalName == "kat")) {
                goto kat;
            }
            else {
                if ((Reader.LocalName == "oigus")) {
                    goto oigus;
                }
                else {
                    if ((Reader.LocalName == "omistatud")) {
                        goto omistatud;
                    }
                    else {
                        if ((Reader.LocalName == "voetud_alates")) {
                            goto voetud_alates;
                        }
                        else {
                            if ((Reader.LocalName == "voetud_kuni")) {
                                goto voetud_kuni;
                            }
                            else {
                                return;
                            }
                        }
                    }
                }
            }
        kat:
            if (Reader.IsElementNil()) {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>pol_juhtoigus>kat");
            }
            clazz.Kat = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("kat")).Value;
            goto START;
        oigus:
            if (Reader.IsElementNil()) {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>pol_juhtoigus>oigus");
            }
            clazz.Oigus = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("oigus")).Value;
            goto START;
        omistatud:
            if (Reader.IsElementNil()) {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>pol_juhtoigus>omistatud");
            }
            clazz.Omistatud = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("omistatud")).Value;
            goto START;
        voetud_alates:
            if (Reader.IsElementNil()) {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>pol_juhtoigus>voetud_alates");
            }
            clazz.VoetudAlates = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("voetud_alates")).Value;
            goto START;
        voetud_kuni:
            if (Reader.IsElementNil()) {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>pol_juhtoigus>voetud_kuni");
            }
            clazz.VoetudKuni = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("voetud_kuni")).Value;
            goto START;
        }
    }
}
